componentDidCatch(error, info) This lifecycle method is invoked after an error has been thrown by a descendant component.
error - The error that was thrown.
info - An object with a componentStack key containing information about which component threw the error.
componentDidCatch() is called during the “commit” phase, so side-effects are permitted.
It should be used for things like logging errors:
How would you add an error boundary around a component that fetches data, and what would you show to the user when an error occurs?
What happens to the UI if a child component throws an error and you haven't implemented componentDidCatch?
We have a third‑party chart library that sometimes throws during render. How would you use componentDidCatch to keep the page alive, and what trade‑offs would you consider for the fallback UI?
During debugging you notice errors in a lazy‑loaded route aren't being caught. Why might componentDidCatch not fire there, and how would you fix it?
In a large app with many nested error boundaries, how would you design a strategy to log errors from componentDidCatch to a central monitoring service without hurting performance?
If a componentDidCatch boundary catches an error but the layout still looks broken, how would you diagnose and resolve the issue considering React's reconciliation process?
Our legacy codebase mixes class components with functional components using hooks. How would you plan a migration to a unified error‑handling approach that leverages componentDidCatch or its hook equivalents while keeping backward compatibility?
When introducing a global error boundary across micro‑frontends, what architectural considerations arise regarding user experience, error reporting, and isolation of failures?